package com.fzz.config;

import com.fzz.conponent.LoginInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;


@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {

       /* registry.addViewController("/login.html").setViewName("login");
    }
    @Bean//把自己写的配置加入到容器中
    public WebMvcConfigurer webMvcConfigurer()
    {
        WebMvcConfigurer mvcConfigurer=new WebMvcConfigurer() {
            @Override

            public void addInterceptors(InterceptorRegistry registry) {

              registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").
                      excludePathPatterns("/login.html","/","/asserts/**","/webjars/**","/layui/**","/img/**");

            }

            @Override
            public void addViewControllers(ViewControllerRegistry registry) {

                registry.addViewController("/").setViewName("login");
                registry.addViewController("/login.html").setViewName("login");
            }
        };
        return mvcConfigurer;*/
    }
}
